package com.cqkjxy.entity;

import com.cqkjxy.commons.entities.AbstractEntity;
import org.springframework.data.domain.Sort;

import javax.persistence.*;

/* *
 * @description 员工管理
 * @author yang tao
 * @date 2021-11-16 15:13
 */
@Entity
@Table(name = "staff_manage")
public class StaffEntity extends AbstractEntity {
    private static final long serialVersionUID = 3089563324611878622L;
    public static final Sort DEFAULT_SORTING = Sort.by(Sort.Direction.ASC, "pkId");

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "pkId", nullable = false)
    private Integer pkId;

    /* *
     * @description 员工姓名
     * @author yang tao
     * @date 2021-11-16 15:13
     */
    @Column(name = "staff_name")
    private String staffName;

    /* *
     * @description 员工所属部门
     * @author yang tao
     * @date 2021-11-16 15:13
     */
    @Column(name = "staff_dep")
    private String staffDep;

    /* *
     * @description 员工总分数
     * @author yang tao
     * @date 2021-12-06 00:15
     * @return
     */
    @Column(name = "staff_score")
    private Double staffScore;

    @Override
    public Integer getPkId() {
        return pkId;
    }

    @Override
    public void setPkId(Integer pkId) {
        this.pkId = pkId;
    }

    public String getStaffName() {
        return staffName;
    }

    public void setStaffName(String staffName) {
        this.staffName = staffName;
    }

    public String getStaffDep() {
        return staffDep;
    }

    public void setStaffDep(String staffDep) {
        this.staffDep = staffDep;
    }

    public Double getStaffScore() {
        return staffScore;
    }

    public void setStaffScore(Double staffScore) {
        this.staffScore = staffScore;
    }

    public StaffEntity() {
    }

    @Override
    public String toString() {
        return "StaffEntity{" +
                "pkId=" + pkId +
                ", staffName='" + staffName + '\'' +
                ", staffDep='" + staffDep + '\'' +
                ", staffScore=" + staffScore +
                '}';
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;//地址相等
        }

        if (obj == null) {
            return false;//非空性：对于任意非空引用x，x.equals(null)应该返回false。
        }

        if (obj instanceof StaffEntity) {
            StaffEntity staff = (StaffEntity) obj;
            //需要比较的字段相等，则这两个对象相等
            if (this.pkId.equals(staff.pkId)) {
                return true;
            }
        }

        return false;
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 1992 * result + (pkId == null ? 0 : pkId.hashCode());
        return result;
    }
}
